<!--  -->
<template>
    <div class='ce'>
        <el-form ref="form" :model="postInfo" label-width="80px" :label-position="labelPosition">
            <el-row>
                <el-col :span="6">
                    <el-form-item label="岗位名称">
                <el-input v-model="postInfo.name"></el-input>
            </el-form-item>
                </el-col>
                <el-col :span="1">|</el-col>
                <el-col :span="6">
                    <el-form-item label="公司名称">
                        <el-input :disabled="true" v-model="postInfo.companyName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="1">|</el-col>
                <el-col :span="6">
                    <el-form-item label="工作地点">
                        <el-input v-model="postInfo.address"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item label="薪水起点/元">
                        <el-input v-model="postInfo.salaryFrom"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="1">|</el-col>
                <el-col :span="6">
                    <el-form-item label="薪水终点/元">
                        <el-input v-model="postInfo.salaryTo"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="1">|</el-col>
                <el-col :span="6">
                    <el-form-item label="结算方式">
                        <el-select v-model="postInfo.way" placeholder="请选择结算方式">
                        <el-option label="天" value="天"></el-option>
                        <el-option label="月" value="月"></el-option>
                        <el-option label="年" value="年"></el-option>
                        <el-option label="面议" value="面议"></el-option>
                    </el-select>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="6">
                    <el-form-item label="学历">
                    <el-select v-model="postInfo.qualification" placeholder="请选择学历要求">
                        <el-option label="不限" value="不限"></el-option>
                        <el-option label="大专" value="大专"></el-option>
                        <el-option label="本科" value="本科"></el-option>
                        <el-option label="硕士" value="硕士"></el-option>
                        <el-option label="博士" value="博士"></el-option>
                    </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="1">|</el-col>
                <el-col :span="6">
                    <el-form-item label="工作经验">
                        <el-select v-model="postInfo.experience" placeholder="请选择工作经验">
                            <el-option label="在校/应届生" value="在校/应届生"></el-option>
                            <el-option label="一年以内" value="一年以内"></el-option>
                            <el-option label="一到三年" value="一到三年"></el-option>
                            <el-option label="三到五年" value="三到五年"></el-option>
                            <el-option label="五到十年" value="五到十年"></el-option>
                            <el-option label="十年以上" value="十年以上"></el-option>
                            <el-option label="经验不限" value="经验不限"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="1">|</el-col>
                <el-col :span="6">
                    <el-form-item label="投递截止时间">
                         <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="postInfo.lastTime" style="width: 100%;">
                    </el-date-picker>
                </el-form-item>

                </el-col>
            </el-row>
            <el-row>
                <el-col :span="20">
                    <el-form-item label="岗位标签（标签是总要的筛选方式，可添加多个，可搜索添加，不支持自定义）">
                        <el-select
                        v-model="postInfo.postLab"
                        size="medium"
                        multiple
                        filterable
                         default-first-option
                         placeholder="请选择岗位标签">
                            <el-option
                            v-for=" (item, index) in postLabs"
                            :key="index"
                            :label="item"
                            :value="item">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="20">
                    <el-form-item label="福利待遇">
                        <el-input   type="textarea" rows="3"  maxlength="200"  show-word-limit v-model="postInfo.treatment">
                    </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="20">
                    <el-form-item label="岗位要求">
                        <el-input   type="textarea" rows="5"  maxlength="500"  show-word-limit v-model="postInfo.requires">
                    </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="20">
                    <el-form-item label="工作任务">
                        <el-input   type="textarea" rows="5"  maxlength="500"  show-word-limit v-model="postInfo.responsibility">
                    </el-input>
                    </el-form-item>
                </el-col>
            </el-row>

        </el-form>
        <el-button type="primary" @click="commitInfo">提交</el-button>
    </div>
    </template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import qs from 'qs'
export default {
  name: 'CompanyPostEdit',
  // import引入的组件需要注入到对象中才能使用
  components: {},
  props: {
  },
  data () {
    // 这里存放数据
    return {
      labelPosition: 'top',
      editType: '',
      postInfo: {
      },
      postLabs: [
        'python', 'java', 'mybatis', 'vue', 'mybatis-plus'
      ]
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    initLab () {
      this.$get('/lab/getAllLab').then(res => {
        this.postLabs = res.data.map(item => { return item.name })
      })
    },
    commitInfo () {
      // 岗位修改/添加
      console.log('当前状态:', this.editType)
      const param = qs.stringify(this.postInfo)
      if (this.editType === 'add') {
        this.$post('/post/addPost', param).then(res => {
          console.log(res.msg)
        })
      } else if (this.editType === 'update') {
        this.$post('/post/updatePost', param).then(res => {
          console.log(res.msg)
        })
      }
      console.log('编辑岗位信息：', this.postInfo)
      // 关闭编辑窗口
      this.$emit('saveEdit')
    },
    // 刷新编辑栏信息
    rushInfo (item, editType) {
    //   const lab = []
    //   if (item.postLab) {
    //     item.postLab.forEach(element => {
    //       lab.push(element.name)
    //     })
    //   }
      this.editType = editType
      console.log('过滤出的标签', item.postLab)
      this.postInfo = item
    }

  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created () {
    this.initLab()
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () {

  },
  beforeCreate () {}, // 生命周期 - 创建之前
  beforeMount () {}, // 生命周期 - 挂载之前
  beforeUpdate () {}, // 生命周期 - 更新之前
  updated () {}, // 生命周期 - 更新之后
  beforeDestroy () {}, // 生命周期 - 销毁之前
  destroyed () {}, // 生命周期 - 销毁完成
  activated () {} // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
    <style lang='less' scoped>
    //@import url(); 引入公共css类

    </style>
